package Code;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.util.ArrayList;
import java.util.List;

public class QuestionNum_23_5_hxj {
    public static void main(String[] args) throws Exception{
        List<String> list = new ArrayList<>();
        list.add("张三");list.add("李四");
        list.add("王五");list.add("二丫");
        list.add("钱六");list.add("孙七");

        System.out.println(list);
        for (String name : list) {
            if (name.equals("二丫")) {
                int index = list.indexOf(name);
                list.set(index, "王小丫");
            } else {
                continue;
            }
        }
        System.out.println(list);

        BufferedWriter bw = new BufferedWriter(new FileWriter("C:\\360Downloads\\1\\stuinfo.txt"));
        bw.write(list.toString());
        bw.close();

    }
}
